﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Scada.DataApi
{
    class NetDataExchange
    {
        private WebClient webClient = null;

        private string address;

        private int port;

        private string basePath;


        public NetDataExchange(string address, int port = 80)
        {
            // TODO: Complete member initialization
            this.address = address;
            this.port = port;

            this.basePath = string.Format("{0}:{1}", this.address, this.port);
        }

        private string GetDataApi(string path)
        {
            return string.Format("{0}/{1}", this.basePath, path);
        }

        private string GetDataApi(string path, Dictionary<string, string> parameters)
        {
            // TODO: parameters.
            return string.Format("{0}/{1}", this.basePath, path);
        }




        internal List<Station> GetStations()
        {
            string result = webClient.DownloadString(GetDataApi("data/stations"));

            return null;
        }


        internal bool SignIn()
        {
            string result = webClient.DownloadString(GetDataApi("user/signIn"));

            return true;
        }

        internal bool SignOut()
        {
            string result = webClient.DownloadString(GetDataApi("user/signOut"));

            return true;
        }

    }
}
